﻿using System;

/*
    Write a program that calculates the greatest common divisor (GCD) of given two numbers.
    Use the Euclidean algorithm (find it in Internet).
 * 
 */

class GreatestCommonDivisor
{
    static void Main(string[] args)
    {
        Console.Write("Enter a = : ");
        int a = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter b = : ");
        int b = Convert.ToInt32(Console.ReadLine());
        
        Console.Write("GCD of {0} and {1} is: ", a, b);
       
        while (a != b)
        {
            // a should always be bigger
            if (a < b)
            {
                a = a + b;
                b = a - b;
                a = a - b;
            }
            a = a - b;
        }

        Console.WriteLine(a);
    }
}

